home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Extensions… / Extension Shell multi-seg ƒ / Extension Seg2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  2.6 KB  |  102 lines  |  [TEXT/MPS ]

  1. /*________________________________________________________
  2.  
  3.     File: Extension Seg2.c
  4.  
  5.     C code for a printing extension.
  6.  
  7.     Dave Hersey
  8.     Apple Developer Technical Support
  9.  
  10.     12/01/92 - dmh - Created.
  11.      4/26/93 - dmh - Updated to use recommended approach
  12.                       to global data initialization.
  13.      9/05/93 - dmh - Updated for b2.
  14.                     - Fixed minor problem with highlighting
  15.                      of editText panel items.
  16.                    - Switched to Exception.h assertion stuff
  17.                      for error checking.
  18.     12/18/93 - dmh - Updated for b3.
  19.      3/22/94 - dmh - Updated for b4.
  20.      6/10/94 - dmh - Added GXPRINTINGDISPATCH examples.
  21.  
  22.     (Note: all functions are in the Mark menu.)
  23.     
  24. __________________________________________________________*/
  25.  
  26. #define SECOND_SEG
  27. #include "Extension.h"
  28. #undef SECOND_SEG
  29.  
  30.  
  31. /*******************************************************************
  32.     SetUpPrintPanel sets up our print panel, adding a default
  33.     ExtensionCollection item to the job collection.  This
  34.     collection item has the values we'll use to set up our panel's
  35.     controls.
  36.     
  37. ********************************************************************/
  38.  
  39. OSErr SetUpPrintPanel()
  40. {
  41.     OSErr                    err;
  42.     gxPanelSetupRecord        panelSetupRec;
  43.     ExtensionCollection        extConfig;
  44.  
  45. // Try to find our collection item.
  46.  
  47.     err = GetCollectionItem(GXGetJobCollection(GXGetJob()),
  48.                             kExtensionCollectionType,
  49.                             gxPrintingTagID,
  50.                             nil,
  51.                             &extConfig);
  52.  
  53.  
  54. // If we don't have an item in the job collection yet, store our default
  55. // settings in it.
  56.  
  57.     if (err == collectionItemNotFoundErr)
  58.     {
  59.         extConfig.extTurnedOn = kDefaultSetting;
  60.     
  61.         err = AddCollectionItem(GXGetJobCollection(GXGetJob()),
  62.                                 kExtensionCollectionType,
  63.                                 gxPrintingTagID,
  64.                                 sizeof(ExtensionCollection),
  65.                                 &extConfig);
  66.  
  67.         nrequire(err, HaveCollectionMgrError);
  68.     }
  69.  
  70.  
  71. // Now, set up the panel.
  72.  
  73.     panelSetupRec.panelResId        = r_ExtensionPanel;        // which panel resource?
  74.     panelSetupRec.resourceRefNum    = GXGetMessageHandlerResFile(); // where is it?
  75.     panelSetupRec.refCon            = 0;                       // we don't use this.
  76.     panelSetupRec.panelKind            = gxExtensionPanel;     // This is an extension panel.
  77.  
  78.     err = GXSetupDialogPanel(&panelSetupRec);
  79.  
  80.  
  81. HaveCollectionMgrError:
  82.     
  83.     return err;
  84. }
  85.  
  86.  
  87. /*******************************************************************
  88.     GetJobCollectionItem is a generic routine that retrieves a
  89.     collection item from the job collection.
  90.     
  91. ********************************************************************/
  92.  
  93. OSErr GetJobCollectionItem(void *collectItem, long *collectSize,
  94.                            OSType collectType, short collectID)
  95. {
  96.     return GetCollectionItem(GXGetJobCollection(GXGetJob()),
  97.                              collectType,
  98.                              collectID,
  99.                              collectSize,
  100.                              collectItem);
  101. }
  102.